<template>
  <ul class="todo-main">
    <!--子组件：todo-item -->
    <todo-item v-for="(todo, index) in todos" :key="index" :todo="todo"></todo-item>
  </ul>
</template>

<script>
  import {mapState} from "vuex";
  import TodoItem from "./todo-item";

  export default {
    name: "todo-list",
    components: {TodoItem},
    computed: {
      //为组件创建计算属性以返回 Vuex store 中的状态，必须走父传子传递数据，不可在子组件中直接...mapState(['todos'])
      ...mapState(['todos'])
    }
  }
</script>

<style scoped>
  /*main*/
  .todo-main {
    margin-left: 0px;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding: 0px;
  }
</style>
